import 'package:json_annotation/json_annotation.dart';
import 'package:smart_devices/params/spare_part.dart';

part 'spare_part.g.dart';

@JsonSerializable()
class SparePartModel {
  /// 备件图片
  String imgUrl;

  /// 备件名称
  String name;

  /// 备件编号
  String code;

  /// 规格型号
  String model;

  ///关联数量
  int count;

  /// 当前库存
  int inventory;

  /// 更换数量
  int change;

  /// 备件类型
  SparePartTypeEnum? type;

  /// 备件单位
  SparePartUnitEnum? unit;

  SparePartModel(
      {required this.imgUrl,
      required this.name,
      required this.code,
      required this.model,
      required this.count,
      this.unit,
      this.type,
      required this.inventory,
      required this.change});

  factory SparePartModel.fromJson(Map<String, dynamic> json) =>
      _$SparePartModelFromJson(json);

  Map<String, dynamic> toJson() => _$SparePartModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}
